package com.demo.redpacket;

import com.jfinal.core.Controller;
import com.jfinal.validate.Validator;

public class RedPacketValidator extends Validator {

	@Override
	protected void validate(Controller c) {
		validateRequired("name", "nameIsNull", "请输入姓名!");
		validateRequired("redpacket.money", "moneyIsNull", "请输入金额!");
		
		validateRegex("redpacket.money", "^[0-9]+(.[0-9]{2})?$", "moneyIsErr", "请输入正确的金额!");
	}

	@Override
	protected void handleError(Controller c) {
		c.renderJson();
	}

}
